home *** CD-ROM | disk | FTP | other *** search
/ Windows Game Programming for Dummies (2nd Edition) / WinGamProgFD.iso / pc / DirectX SDK / DXSDK / samples / Multimedia / DirectShow / Players / DDrawXCL / vidplay.h < prev   
Encoding:
C/C++ Source or Header  |  2001-10-08  |  5.4 KB  |  143 lines

  1. //------------------------------------------------------------------------------
  2. // File: VidPlay.h
  3. //
  4. // Desc: DirectShow sample code - video (DVD and file) playback 
  5. //       class header file.
  6. //
  7. // Copyright (c) 1993-2001 Microsoft Corporation.  All rights reserved.
  8. //------------------------------------------------------------------------------
  9.  
  10.  
  11. // Suppress C4127: conditional expression is constant
  12. #pragma warning(disable:4127)
  13.  
  14. //
  15. // Some enumerated type definitions...
  16. //
  17.  
  18. // Player state
  19. typedef enum {
  20.     Uninitialized = 0, Stopped, Paused, Playing, Scanning
  21. } PLAYER_STATE ;
  22.  
  23. // Define a special WM message for playback related events from DShow filtergraph
  24. #define WM_PLAY_EVENT     WM_USER + 100
  25. #define WM_SIZE_CHANGE    WM_USER + 101
  26.  
  27. #define DEFAULT_WIDTH   400
  28. #define DEFAULT_HEIGHT  240
  29.  
  30.  
  31. //
  32. // Video Playback base class
  33. //
  34. class CBaseVideoPlayer
  35. {
  36. public:   // public methods for Windows structure to call
  37.     CBaseVideoPlayer(void) ;
  38.     ~CBaseVideoPlayer(void) ;
  39.     
  40.     virtual BOOL    Initialize(void) = 0 ;
  41.     virtual HRESULT BuildGraph(HWND hWndApp, LPDIRECTDRAW pDDObj, 
  42.         LPDIRECTDRAWSURFACE pDDPrimary) = 0 ;
  43.     virtual HRESULT ClearGraph(void) = 0 ;
  44.     virtual HRESULT GetNativeVideoData(DWORD *pdwWidth, DWORD *pdwHeight, DWORD *pdwARX, DWORD *pdwARY) = 0 ;
  45.     virtual HRESULT SetVideoPosition(DWORD dwLeft, DWORD dwTop, DWORD dwWidth, DWORD dwHeight) = 0 ;
  46.     virtual HRESULT GetInterfaces(HWND hWndApp) ;
  47.     virtual HRESULT SetOverlayCallback(IDDrawExclModeVideoCallback *pCallback) = 0 ;
  48.     HRESULT GetColorKey(DWORD *pdwColorKey) ;
  49.     BOOL    Play(void) ;
  50.     BOOL    Pause(void) ;
  51.     BOOL    Stop(void) ;
  52.     inline  void    SetFileName(LPCTSTR lpszFileName)   { lstrcpy(m_achFileName, lpszFileName) ; } ;
  53.     inline  BOOL    IsGraphReady(void)                  { return (Uninitialized != m_eState) ; } ;
  54.     inline  PLAYER_STATE GetState(void)                 { return m_eState ; } ;
  55.     inline  void    SetColorKey(DWORD dwColorKey)       { m_dwColorKey = dwColorKey ; } ;
  56.     inline  LPCTSTR GetFileName(void)                   { return m_achFileName ; } ;
  57.     
  58. protected:
  59.     virtual void    ReleaseInterfaces(void) ;
  60.     virtual HRESULT GetColorKeyInternal(IBaseFilter *pOvM = NULL) = 0 ;
  61.     
  62. private:
  63.     void    WaitForState(FILTER_STATE State) ;
  64.     
  65. protected:  // semi-internal state info (to be shared with derived classes)
  66.     IGraphBuilder  *m_pGraph ;        // IGraphBuilder interface
  67.     
  68. private:    // internal state info
  69.     PLAYER_STATE    m_eState ;        // player state (run/pause/stop/...)
  70.     TCHAR           m_achFileName[MAX_PATH] ; // current file name
  71.     
  72.     IMediaControl  *m_pMC ;           // IMediaControl interface
  73.     IMediaEventEx  *m_pME ;           // IMediaEventEx interface
  74.     
  75.     DWORD           m_dwColorKey ;    // color key to be used for video
  76. } ;
  77.  
  78.  
  79. //
  80. // DVD Playback class
  81. //
  82. class CDVDPlayer : public CBaseVideoPlayer
  83. {
  84. public:   // public methods for Windows structure to call
  85.     CDVDPlayer(void) ;
  86.     ~CDVDPlayer(void) ;
  87.     
  88.     BOOL    Initialize(void) ;
  89.     
  90.     HRESULT BuildGraph(HWND hWndApp, LPDIRECTDRAW pDDObj, LPDIRECTDRAWSURFACE pDDPrimary) ;
  91.     HRESULT ClearGraph(void) ;
  92.     HRESULT GetNativeVideoData(DWORD *pdwWidth, DWORD *pdwHeight, DWORD *pdwARX, DWORD *pdwARY) ;
  93.     HRESULT SetVideoPosition(DWORD dwLeft, DWORD dwTop, DWORD dwWidth, DWORD dwHeight) ;
  94.     HRESULT GetInterfaces(HWND hWndApp) ;
  95.     HRESULT SetOverlayCallback(IDDrawExclModeVideoCallback *pCallback) ;
  96.     
  97. private:  // private helper methods for the class' own use
  98.     void    ReleaseInterfaces(void) ;
  99.     HRESULT GetColorKeyInternal(IBaseFilter *pOvM = NULL) ;
  100.     DWORD   GetStatusText(AM_DVD_RENDERSTATUS *pStatus, 
  101.         LPTSTR lpszStatusText,
  102.         DWORD dwMaxText) ;
  103.     
  104. private:  // internal state info
  105.     IDvdGraphBuilder  *m_pDvdGB ;         // IDvdGraphBuilder interface
  106.     IDvdInfo2         *m_pDvdI ;          // IDvdInfo interface
  107.     IDvdControl2      *m_pDvdC ;          // IDvdControl interface
  108. } ;
  109.  
  110.  
  111. //
  112. // File Playback class
  113. //
  114. class CFilePlayer : public CBaseVideoPlayer
  115. {
  116. public:   // public methods for Windows structure to call
  117.     CFilePlayer(void) ;
  118.     ~CFilePlayer(void) ;
  119.     
  120.     BOOL    Initialize(void) ;
  121.     
  122.     HRESULT BuildGraph(HWND hWndApp, LPDIRECTDRAW pDDObj, LPDIRECTDRAWSURFACE pDDPrimary) ;
  123.     HRESULT ClearGraph(void) ;
  124.     HRESULT GetNativeVideoData(DWORD *pdwWidth, DWORD *pdwHeight, DWORD *pdwARX, DWORD *pdwARY) ;
  125.     HRESULT SetVideoPosition(DWORD dwLeft, DWORD dwTop, DWORD dwWidth, DWORD dwHeight) ;
  126.     HRESULT GetInterfaces(HWND hWndApp) ;
  127.     HRESULT SetOverlayCallback(IDDrawExclModeVideoCallback *pCallback) ;
  128.     
  129. private:  // private helper methods for the class' own use
  130.     void    ReleaseInterfaces() ;
  131.     HRESULT GetColorKeyInternal(IBaseFilter *pOvM = NULL) ;
  132.     BOOL    IsOvMConnected(IBaseFilter *pOvM) ;
  133.     HRESULT GetVideoRendererInterface(IBaseFilter **ppVR) ;
  134.     HRESULT AddOvMToGraph(IBaseFilter **ppOvM, LPDIRECTDRAW pDDObj, 
  135.         LPDIRECTDRAWSURFACE pDDPrimary) ;
  136.     HRESULT SetDDrawParams(IBaseFilter *pOvM, LPDIRECTDRAW pDDObj, 
  137.         LPDIRECTDRAWSURFACE pDDPrimary) ;
  138.     HRESULT PutVideoThroughOvM(IBaseFilter *pOvM, IBaseFilter *pVR) ;
  139.     
  140. private:  // internal state info
  141.     IDDrawExclModeVideo *m_pDDXM ;       // IDDrawExclModeVideo interface
  142. } ;
  143.